﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Team : IEnumerable<IDeveloperBase>
    {
        List<IDeveloperBase> Devs = default(List<IDeveloperBase>);

        private FactoryBase f = default(FactoryBase);
        public int TeamSize = default(int);
        
        public Team(FactoryBase f2)
        {
            f = f2;
            Devs = new List<IDeveloperBase>();
        }

        public void Add()
        {
            Devs.Add((IDeveloperBase)f.GetFrontBackDeveloper());
            Devs.Add((IDeveloperBase)f.GetFrontEndDeveloper());
        }

        public void CreateAllTeam(int TeamSize)
        {
            for (int i = 0; i < TeamSize / 2; i++)
            {
                Devs.Add((IDeveloperBase)f.GetFrontBackDeveloper());
                Devs.Add((IDeveloperBase)f.GetFrontEndDeveloper());
            }
        }

        public override string  ToString()
         {
             StringBuilder SBstring = new StringBuilder();
             foreach (var dev in Devs)
             {
                 SBstring.AppendLine(dev.ToString());
             }
             return SBstring.ToString();
         }

        public IEnumerator<IDeveloperBase> GetEnumerator()
        {
            return Devs.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return Devs.GetEnumerator();
        }

        IEnumerator<IDeveloperBase> IEnumerable<IDeveloperBase>.GetEnumerator()
        {
            return Devs.GetEnumerator();
        }
    }
}
